package com.lg.concurrent.pool.thread_pool;

import java.util.ArrayList;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class PriorityBlockingQueueTest {
    private static PriorityBlockingQueue<Task> queue = new PriorityBlockingQueue<>();

    public static void main(String[] args) {
        int num = 5;
        ArrayList<Task> tasks = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            queue.add(new Task(i));
        }

        for (int i = 0; i < num; i++) {
            System.out.println(queue.poll().getValue());
        }

        System.out.println("--------------------------");

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,2,0, TimeUnit.SECONDS,new PriorityBlockingQueue<>());

        for (int i = 0; i < num; i++) {
            threadPoolExecutor.execute(new Task(i));
        }
        int poolSize = threadPoolExecutor.getPoolSize();


    }
}
